<h1><span></span><?= lang('label_your_invoicies') ?></h1>

<ul class="breadcrumb">
    <li><a href="<?= base_url() ?>"><?= lang('label_home') ?></a></li>
    <li><a href="<?= base_url('user/profile') ?>"><?= lang('label_profile') ?></a></li>
    <li><?= lang('label_your_invoicies'); ?></li>
</ul>


<div class="page">
    <?php $this->load->view('template/default/invoicies/top') ?>

    <div style="overflow:hidden;">
        <?php if ($result) { ?>
            <table id="tablestyle">
                <thead>
                    <tr class="head-row">
                        <th><?= lang('label_inv_num') ?></th>
                        <th><?= lang('label_title') ?></th>
                        <th><?= lang('label_inv_total') ?></th>
                        <th><?= lang('label_payment_date') ?></th>
                        <th><?= lang('label_confirm_date') ?></th>
                        <th style="width:300px;"><?= lang('label_wallet_note') ?></th>
                        <th><?= lang('label_created_date') ?></th>
                        <th><?= lang('label_operation') ?></th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                    foreach ($result as $value) {
                        ?>
                        <tr class="row" <?php if ($value->cancel != 'NO') { ?> style="background-color: #f7e4e4; text-decoration: line-through" title="<?= lang('label_canceled_by_' . strtolower($value->cancel)) ?>"<?php } ?>>
                            <td><?= strtoupper($value->inv_num) ?></td>
                            <td><?= lang($value->title) ?></td>
                            <td><?= $value->must_pay ?></td>
                            <td><?php
                                $pa = $value->payment_status;
                                if ($pa == 'YES') {
                                    echo lang('label_payment_yes') . '<br />' . $value->payment_date;
                                } else {
                                    echo lang('label_payment_no');
                                }
                                ?></td>
                            <td><?php
                                $co = $value->confirm_status;
                                if ($co == 'YES') {
                                    echo lang('label_confirm_yes') . '<br />' . $value->confirm_date;
                                } else {
                                    echo lang('label_confirm_no');
                                }
                                ?></td>
                            <td><?= ($value->note) ? $value->note : lang('label_no_notes') ?></td>
                            <td><?= timespan($value->create_date) ?> </td>
                            <td>
                                <?php if (in_array($value->cancel, array('USER', 'ADMIN'))) { ?>
                                    <h4 style="color: red; text-decoration: none"><?= lang('label_canceled_by_' . strtolower($value->cancel)) ?></h4>
                                <?php } else { ?>
                                    <a href="<?= base_url('invoicies/show/' . $value->inv_num); ?>" ><?= lang('label_show') ?></a>
                                    <?php if ($value->payment_status == 'NO' && $value->confirm_status == 'YES') { ?>
                                        <a href="<?= base_url('invoicies/pay/' . $value->inv_num); ?>" ><?= lang('label_pay_the_bill') ?></a>
                                    <?php } ?>
                                    <?php if ($value->payment_status == 'NO') { ?>
                                        <a href="<?= base_url('invoicies/cancel/' . $value->inv_num); ?>" ><?= lang('label_cancel') ?></a>
                                    <?php } ?>
                                <?php } ?>
                            </td>
                        </tr>
                    <? } ?>
                </tbody>
            </table>
        <?php } else { ?>
            <div class="unsaved">
                <img src="<?php echo str_replace('/index.php', '', $_SERVER['SCRIPT_NAME']) ?>/<?php echo APPPATH ?>views/<?php echo $this->themes->Cms_themes() ?>/images/unsaved.png" alt="" />
                <br /><?= lang('message_no_invoicies_found') ?>
            </div>
            <br /><br /><br /><br />
        <?php } ?>
    </div>
</div>